package com.sc.config;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.sql.Connection;
import java.util.Properties;

public class DataSourceConfig {
    public DataSourceConfig() {
    }

    public static DataSource getDruidDataSource() throws Exception {
        Properties properties = new Properties();
        properties.load(new FileInputStream("druid.properties"));
        return DruidDataSourceFactory.createDataSource(properties);
    }

    public static Connection getConnection() throws Exception {
        return getDruidDataSource().getConnection();
    }
}
